package br.ufpe.cin.msc.jrsj2.recommender.algorithm.cb;

import java.util.ArrayList;
import java.util.List;

import br.ufpe.cin.msc.jrsj2.recommender.algorithm.RecommendationAlgorithm;
import br.ufpe.cin.msc.jrsj2.recommender.persistence.domain.Client;
import br.ufpe.cin.msc.jrsj2.recommender.persistence.domain.Profile;
import br.ufpe.cin.msc.jrsj2.recommender.persistence.domain.Program;

public class AttributeBased extends RecommendationAlgorithm implements
		ContentFiltering {

	public AttributeBased(Client activeClient, List<Program> itens,
			List<Profile> activeProfileList) {
		super(activeClient, itens, activeProfileList);
	}

	@Override
	public List<Program> getRecommendations(int size) {
		List<Program> recommendations = new ArrayList<Program>();

		for (Profile profile : activeProfileList) {
			if (recommendations.size() == size)
				break;
			for (Program program : itens)
				if (profile.getProgram().getGenre().equals(program.getGenre())
						&& !recommendations.contains(program)) {
					recommendations.add(program);
					break;
				}
		}

		return recommendations;
	}

}
